function Menu(){
	this.enlaces = [];
	this.posicion = 0;
}

Menu.prototype = {
	crearMenu : function(){
		this.enlaces.push(new Enlace("Start","20px Arial",100,150,"1"));
		this.enlaces.push(new Enlace("Opciones","20px Arial",100,200,"0"));
		this.enlaces.push(new Enlace("Creditos","20px Arial",100,250,"0"));
		this.enlaces.push(new Enlace("Exit","20px Arial",100,300,"0"));
	},
	
	movePosicion : function(){
		this.posicion +=1; 
	},
	
	downSelect : function(){
		
		for(var i=0; i< this.enlaces.length; i++){
			this.enlaces[i].selected = 0;
		}
		
		if(this.posicion + 1 < this.enlaces.length){
			this.enlaces[this.posicion + 1].selected = 1;
			this.posicion = this.posicion + 1;
		}else{
			this.enlaces[0].selected = 1;
			this.posicion = 0;
		}		
	},
	
	upSelect : function(){
		
		for(var i=0; i< this.enlaces.length; i++){
			this.enlaces[i].selected = 0;
		}
		
		if(this.posicion - 1 >= 0){
			this.enlaces[this.posicion-1].selected = 1;
			this.posicion = this.posicion -1;
		}else{
			this.enlaces[this.enlaces.length-1].selected = 1;
			this.posicion = this.enlaces.length-1;
		}		
	},
	
	menuControles : function(){
		
		if(UP==1){
			this.upSelect();
			UP=0;
		}
		
		if(DOWN==1){
			this.downSelect();
			DOWN =0;
		}		
		
		if(ENTER==1){
			switch(this.enlaces[this.posicion].texto){
				case "Start":
					game=2;
				break;
				
				case "Exit":
					game=10;
				break;
			}
		}

	},
	
}


function Enlace(texto,font,x,y,selected){
	this.texto=texto;
	this.textoSelected = "> " + texto + " <";
	this.font=font;
	this.x=x;
	this.y=y;	
	this.selected=selected;
}

Enlace.prototype = {
	returnTexto : function(){
		if(this.selected == 1){
			return this.textoSelected;
		}else{
			return this.texto;
		}
	},
	
	
}

